<template>
  <div class="app-container">
    <el-form :inline="true" :model="pageInfo" class="demo-form-inline">
      <el-form-item label="租客姓名">
        <el-input v-model="pageInfo.tenantName" placeholder="请输入租客姓名"></el-input>
      </el-form-item>
      <el-form-item label="房源类型">
        <el-select v-model="pageInfo.signType" placeholder="请选择">
          <el-option label="请选择" value=null></el-option>
          <el-option label="整租(分散式)" value="0"></el-option>
          <el-option label="合租(分散式)" value="1"></el-option>
          <el-option label="公寓(集中式)" value="2"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="手机号码">
        <el-input v-model="pageInfo.tenantPhone" placeholder="请输入手机号码"></el-input>
      </el-form-item>
      <el-form-item label="小区名称">
        <el-input v-model="pageInfo.premiseName" placeholder="请输入小区名称"></el-input>
      </el-form-item>
      <el-form-item label="起租日期">
        <el-date-picker
          v-model="pageInfo.startDate"
          type="date"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
      </el-form-item>
    </el-form>
    <template>
      <el-table
        :data="tableData"
        style="width: 100%">
        <el-table-column
          prop="tenantName"
          label="租客姓名"
          width="180">
        </el-table-column>
        <el-table-column
          prop="cfContractNo"
          label="租房合同编号"
          width="180">
        </el-table-column>
        <el-table-column
          prop="tenantPhone"
          label="电话"
          width="180">
        </el-table-column>
        <el-table-column
          prop="roomName"
          label="房源信息"
          width="180">
        </el-table-column>
        <el-table-column
          prop="signType"
          label="房源类型">
          <template slot-scope="scope">
            <span v-if="scope.row.signType==0">整租(分散式)</span>
            <span v-if="scope.row.signType==1">合租(分散式)</span>
            <span v-if="scope.row.signType==2">公寓(集中式)</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="startDate"
          label="起租日期"
          width="180">
        </el-table-column>
        <el-table-column
          prop="endDate"
          label="结束日期"
          width="180">
        </el-table-column>
        <el-table-column
          label="押付方式"
          width="180">
          <template slot-scope="scope">
              <span>押{{scope.row.depositType}}付{{scope.row.paymentType}}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="deposit"
          label="押金"
          width="180">
        </el-table-column>
        <el-table-column
          prop="monthRent"
          label="租金"
          width="180">
        </el-table-column>
        <el-table-column
          prop="contractState"
          label="状态">
          <template slot-scope="scope">
            <span v-if="scope.row.contractState==1">草稿</span>
            <span v-if="scope.row.contractState==2">已提交</span>
            <span v-if="scope.row.contractState==3">已解约</span>
            <span v-if="scope.row.contractState==4">已结束</span>
            <span v-if="scope.row.contractState==9">作废</span>
          </template>
        </el-table-column>
      </el-table>
    </template>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageInfo.pageNum"
      :page-sizes="[10, 30, 50, 70]"
      :page-size="pageInfo.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</template>

<script>
import axios from "axios";
export default {
  created() {
    this.list()
  },
  name: "contract",
  data() {
    return {
      tableData: [],
      pageInfo:{
        pageNum:1,
        pageSize:10,
        tenantName:null,
        tenantPhone:null,
        signType:null,
        premiseName:null,
        startDate:null
      },
      total:null,
      form:{
        id:'',
        tenantName:'',
        cfContractNo:'',
        tenantPhone:'',
        roomName:'',
        signType:'',
        startDate:'',
        endDate:'',
        depositType:'',
        paymentType:"",
        deposit:'',
        monthRent:'',
        contractState:''
      }
    }
  },
  methods: {
    list() {
      axios.get("http://localhost:8200/hou/tcfContractController/selects", {params: this.pageInfo}).then((response) => {
        console.log(response.data)
        this.tableData = response.data.obj.list
        this.pageInfo.pageNum = response.data.obj.pageNum
        this.pageInfo.pageSize = response.data.obj.pageSize
        this.total = response.data.obj.total
      })
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
      this.pageInfo.pageSize = val
      this.list()
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
      this.pageInfo.pageNum = val
      this.list()
    },
    onSubmit() {
      console.log('submit!')
      this.list()
    }
  }
}
</script>

<style scoped>

</style>
